package jinyilw.common;

public class ThreadTools
{
	public static final int maxCore = Runtime.getRuntime()
			.availableProcessors();
	private ThreadTools()
	{
	}

	public static void executeInThread(final Operator<?> operator)
	{
		if (operator != null)
			new Thread(operator).start();
	}

	public static void startAndJoin(Thread[] threads)
	{
		for (Thread t : threads)
		{
			t.setPriority(Thread.NORM_PRIORITY);
			t.start();
		}

		try
		{
			for (Thread t : threads)
				t.join();
		} catch (InterruptedException ie)
		{
			throw new RuntimeException(ie);
		}
	}
}
